package com.atcumt.xiaoyuan;

import java.util.Scanner;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class HJOD02 {
    /**
     * 提取字符串中最长的数学表达式计算
     * @param args
     */
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        String maxExp = findMaxExp(str);
        if (maxExp == null || maxExp.length() == 0) {
            System.out.println(0);;
        } else {
            int res = evaluate(maxExp);
            System.out.println(res);
        }
    }

    public static String findMaxExp(String str) {
        Pattern compile = Pattern.compile("([+-]?(\\d+[+*-])*\\d+)");
        Matcher matcher = compile.matcher(str);
        String maxExp = "";
        while (matcher.find()) {
            String expStr = matcher.group(0);
            if (expStr.length() > maxExp.length()) {
                maxExp = expStr;
            }
        }
        return maxExp;
    }
    public static int evaluate(String exp) {
        exp += "+0";
        Stack<Integer> stack = new Stack<>();
        String num = "";
        int numCoef = 1;
        char start = exp.charAt(0);
        if (start == '+' || start == '-') {
            exp = exp.substring(1);
        }
        if (start == '-') {
            numCoef = -1;
        }
        char[] charArray = exp.toCharArray();
        for (char ch : charArray) {
            if (ch >= '0' && ch <= '9') {
                num += ch;
                continue;
            }
            int numTemp = numCoef * Integer.parseInt(num);
            stack.push(numTemp);
            num = "";
            if (ch == '+') {
                numCoef = 1;
            } else if(ch == '-') {
                numCoef = -1;
            } else if (ch == '*') {
                numCoef = stack.pop();
            }
        }
        int res = 0;
        while (!stack.isEmpty()) {
            res += stack.pop();
        }
        return res;
    }

}
